package com.xcity.game.currency.factory;

import com.xcity.game.currency.CurrencyType;
import com.xcity.game.currency.ICurrency;
import com.xcity.game.currency.ICurrencyFactory;
import com.xcity.game.currency.IntCurrency;
import com.xcity.game.currency.impl.Gold;
import com.xcity.game.currency.impl.Stone;
import com.xcity.game.currency.impl.Strength;
import com.xcity.game.io.DeserializeStream;
import com.xcity.pomelo.push.SyncPush;

public final class DefaultCurrencyFactory implements ICurrencyFactory {
	
	private static final DefaultCurrencyFactory INSTANCE = new DefaultCurrencyFactory();
	
	private DefaultCurrencyFactory() {
	}
	
	@Override
	public ICurrency create(CurrencyType type, DeserializeStream stream) {
		if (type == CurrencyType.GOLD) {
			return new Gold(stream);
		}
		if (type == CurrencyType.STONE) {
			return new Stone(stream);
		}
		if (type == CurrencyType.STRENGTH) {
			return new Strength(stream);
		}
		if (type == CurrencyType.HONOR) {
			return new IntCurrency(type, SyncPush.SYNC_HONOR,
					"[ADDHONOR]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", "[DECHONOR]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", stream);
		}
		if (type == CurrencyType.KING_COIN) {
			return new IntCurrency(type, SyncPush.SYNC_KING_COIN,
					"[ADDKGCOIN]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", "[DECKGCOIN]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", stream);
		}
		if (type == CurrencyType.PEAK_COIN) {
			return new IntCurrency(type, SyncPush.SYNC_PEAK_COIN,
					"[ADDPEAKCOIN]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", "[DECPEAKCOIN]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", stream);
		}
		if (type == CurrencyType.VIGOUR) {
			return new IntCurrency(type, SyncPush.SYNC_VIGOUR,
					"[ADDVIGOUR]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", "[DECVIGOUR]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", stream);
		}
		if (type == CurrencyType.BOND) {
			return new IntCurrency(type, SyncPush.SYNC_BOND,
					"[ADDBOND]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", "[DECBOND]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", stream);
		}
		if (type == CurrencyType.STAGE_STARS) {
			return new IntCurrency(type, SyncPush.SYNC_STAGE_STARS,
					"[ADDSSTARS]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", "[DECSSTARS]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", stream);
		}
		if (type == CurrencyType.CIRCLE_SCORE) {
			return new IntCurrency(type, (short) 0,
					"[CIRCLESCORE]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", "[CIRCLESCORE]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", stream);
		}
		if (type == CurrencyType.SKILL_POINTS) {
			return new IntCurrency(type, SyncPush.SYNC_SKILL_POINTS,
					"[ADDSKP]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]",
					"[DECSKP]ID[{}]OLD[{}]NEW[{}]CAUSE[{}]", stream);
		}
		if (stream != null) {
			stream.read();
		}
		return null;
	}
	
	public static ICurrencyFactory getInstance() {
		return INSTANCE;
	}

}
